- Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy path700.Search in a Binary Search Tree_test.go
51 lines (42 loc) · 1.1 KB
/
700.Search in a Binary Search Tree_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package leetcode
import (
"fmt"
"testing"
)
typequestion700struct {
para700
ans700
}
// para 是参数
typepara700struct {
root*TreeNode
valint
}
// ans 是答案
typeans700struct {
ans*TreeNode
}
funcTest_Problem700(t*testing.T) {
qs:= []question700{
{
para700{&TreeNode{Val: 4,
Left: &TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}},
Right: &TreeNode{Val: 7, Left: nil, Right: nil}},
2},
ans700{&TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}}},
},
{
para700{&TreeNode{Val: 4,
Left: &TreeNode{Val: 2, Left: &TreeNode{Val: 1, Left: nil, Right: nil}, Right: &TreeNode{Val: 3, Left: nil, Right: nil}},
Right: &TreeNode{Val: 7, Left: nil, Right: nil}},
5},
ans700{nil},
},
}
fmt.Printf("------------------------Leetcode Problem 700------------------------\n")
for_, q:=rangeqs {
_, p:=q.ans700, q.para700
fmt.Printf("【input】:%v 【output】:%v\n", p, searchBST(p.root, p.val))
}
fmt.Printf("\n\n\n")
}